﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.OleDb;
using System.Configuration;
using System.Data;

/// <summary>
/// Summary description for Room
/// </summary>
public class Room
{
    public int room_No { set; get; }
    public String room_Name { set; get; }
    public String connString = "SELECT * FROM Classroom WHERE Room_no = @Room";

	public Room()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    //public Room getRoomByNo(int roomNo)
    //{
    //    OleDbConnection myOleDbConnection = new OleDbConnection();
    //    myOleDbConnection.ConnectionString = ConfigurationManager.ConnectionStrings["AssetDbConnection"].ConnectionString;

    //    OleDbCommand myOleDbCommand = myOleDbConnection.CreateCommand();
    //    myOleDbCommand.CommandText = connString;

    //    myOleDbConnection.Open();
    //    OleDbDataAdapter da = new OleDbDataAdapter(connString, myOleDbConnection);

    //    OleDbParameter computerIDParam = new OleDbParameter();
    //    computerIDParam.ParameterName = "@Hardware";
    //    computerIDParam.OleDbType = OleDbType.Numeric;
    //    computerIDParam.Size = 255;
    //    computerIDParam.Direction = ParameterDirection.Input;
    //    computerIDParam.Value = roomNo;

    //    myOleDbCommand.Parameters.Add(computerIDParam);

    //    //myOleDbCommand.Connection.Open();
    //    OleDbDataReader dataReader = myOleDbCommand.ExecuteReader(CommandBehavior.CloseConnection);
    //    Room room = new Room();
    //    while (dataReader.Read())
    //    {
    //        room.room_No = Int32.Parse(dataReader["Room_No"].ToString());
    //        room.room_Name = dataReader["Room_Name"].ToString();
    //    }

    //    myOleDbConnection.Close();
    //    myOleDbCommand.Connection.Close();

    //    return room;
    //}


    //public int update(Room room)
    //{
    //    int RecordsAffected;

    //    OleDbCommand myOleDbCommand;
    //    OleDbConnection myOleDbConnection = new OleDbConnection();
    //    myOleDbConnection.ConnectionString = ConfigurationManager.ConnectionStrings["AssetDbConnection"].ConnectionString;


    //    String connStringUpdate = "UPDATE Classroom SET Room_Name = '" + room.room_Name + "' WHERE Room_No = " + room.room_No + ";";

    //    myOleDbCommand = new OleDbCommand(connStringUpdate, myOleDbConnection);
    //    myOleDbConnection.Open();

    //    RecordsAffected = myOleDbCommand.ExecuteNonQuery();
    //    myOleDbConnection.Close();

    //    return RecordsAffected;
    //}

    //public List<Room> getAllRooms()
    //{
    //    List<Room> roomList = new List<Room>();
    //    OleDbConnection myOleDbConnection = new OleDbConnection();
    //    myOleDbConnection.ConnectionString = ConfigurationManager.ConnectionStrings["AssetDbConnection"].ConnectionString;

    //    OleDbCommand myOleDbCommand = myOleDbConnection.CreateCommand();
    //    myOleDbCommand.CommandText = "SELECT * FROM Classroom;";
    //    myOleDbConnection.Open();

    //    //myOleDbCommand.Connection.Open();
    //    OleDbDataReader dataReader = myOleDbCommand.ExecuteReader(CommandBehavior.CloseConnection);
    //    Room room = new Room();
    //    while (dataReader.Read())
    //    {
    //        room.room_No = Int32.Parse(dataReader["Room_No"].ToString());
    //        room.room_Name = dataReader["Room_Name"].ToString();
    //        roomList.Add(room);
    //    }

    //    myOleDbConnection.Close();
    //    myOleDbCommand.Connection.Close();

    //    return roomList;
    //}






}